package com.rlm.parken.client.views;

import java.util.List;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
import com.rlm.parken.client.FlowControl;
import com.rlm.parken.client.views.DatenParsenInArrayList.Callback;
import com.rlm.parken.client.views.DatenParsenInArrayList.Kneipe;

public class VCard extends Composite {

	private static VCardUiBinder uiBinder = GWT.create(VCardUiBinder.class);

	@UiField
	Label ortLabel;
	@UiField
	Label nameLabel;
	@UiField
	Label nameHeader;
	@UiField
	Image imageWidget;

	@UiHandler("backButton")
	void handleBackButton(ClickEvent event) {
		FlowControl.go(new DatenTabelleAusgeben());
	}

	interface VCardUiBinder extends UiBinder<Widget, VCard> {
	}

	public VCard(final int id) {

		final DatenParsenInArrayList parser = new DatenParsenInArrayList();

		parser.dateiEinlesen(new Callback() {

			@Override
			public void onDataAvailable(List<Kneipe> Kneipen) {
				nameLabel.setText(Kneipen.get(id).name);
				ortLabel.setText(Kneipen.get(id).ort);
				nameHeader.setText(Kneipen.get(id).name);
				imageWidget.setUrl("bilder/" + Kneipen.get(id).bild);
				imageWidget.setAltText(Kneipen.get(id).name + " in "
						+ Kneipen.get(id).ort);

			}

		});

		initWidget(uiBinder.createAndBindUi(this));
	}

}
